package com.xtool.livewallpaper.util

import java.text.SimpleDateFormat
import java.util.*

/**
 *
 * @Author: Ricky
 * @Date: 2021/1/24
 */
object DateTimeUtil {
    const val DEFAULT_STYLE = "yyyy/MM/dd HH:mm:ss"
    const val CHINESE_STYLE = "yyyy年MM月dd日 HH:mm:ss"
    const val NO_WORDS_STYLE = "yyyyMMddHHmmss"
    const val DATE_STYLE = "yyyy/MM/dd"
    const val DATE_STYLE1 = "yyyy-MM-dd"
    const val TIME_STYLE = "HH:mm:ss"
    private val chineseWeekList = arrayListOf("星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")
    fun formatTime(timestamp: Long, style: String = DEFAULT_STYLE): String {
        return SimpleDateFormat(style, Locale.CHINA).format(timestamp)
    }

    fun formatNow(style: String = DEFAULT_STYLE): String {
        return formatTime(System.currentTimeMillis(), style)
    }

    fun getNowWeek(): String {
        val cal = Calendar.getInstance()
        cal.time = Date(System.currentTimeMillis())
        val dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) - 1
        return chineseWeekList[dayOfWeek]
    }
}